/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
* ProgCurveIModel.java
*
* Created on December 29, 2007, 10:41 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
 */
package gui.genomemap.inputModel;

import gui.genomemap.inputModel.optOperations.ProgCurveOptionalOperModel;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author stewari1
 */
@Entity
public class ProgCurveIModel extends InputModel implements java.io.Serializable {

    /** Field description */
    private int annealCriterion = 0;

    /** Field description */
    private int annealMachineType = 0;

    /** Field description */
    private int segProbeCount = 10;

    /** Field description */
    private int segmentCount = 1;

    /** Field description */
    @OneToMany(cascade = CascadeType.ALL)
    private Set<AnnealIModel> annealIModelSet = new LinkedHashSet<>();

    /** Field description */
    @OneToOne(cascade = CascadeType.ALL)
    private AnnealIModel annealInputOptions = new AnnealIModel();

    /** Field description */
    @OneToOne(cascade = CascadeType.ALL)
    private ProgCurveOptionalOperModel optionalOperModel = new ProgCurveOptionalOperModel();

    /** Creates a new instance of ProgCurveIModel */
    public ProgCurveIModel() {}

    @Override
    public int hashCode() {

        return super.hashCode() + new Integer(annealCriterion).hashCode()
               + new Integer(segProbeCount).hashCode() + new Integer(segmentCount).hashCode()
               + new Integer(annealCriterion).hashCode() + getAnnealIModelSet().hashCode();
    }

    /**
     * Note that <CODE>optionalOperModel</CODE> is not included in the <CODE>hashCode</CODE>
     * and <CODE>equals</CODE> implementation. This is to differentiate between the
     * core input setings that would require a fresh LHood computation from optional
     * operations which do not require a fresh LHood computation except for few
     * (SE computation if the accuracy wasn`t up to the required level).
     */
    @Override
    public boolean equals(Object obj) {

        if (obj instanceof ProgCurveIModel) {

            if (super.equals(obj)) {

                ProgCurveIModel inputModel = (ProgCurveIModel) obj;

                return (this.getAnnealCriterion() == inputModel.getAnnealCriterion())
                       && (this.getSegProbeCount() == inputModel.getSegProbeCount())
                       && (this.getSegmentCount() == inputModel.getSegmentCount())
                       && (this.getAnnealCriterion() == inputModel.getAnnealCriterion())
                       && this.getAnnealIModelSet().equals(inputModel.getAnnealIModelSet());
            }

            return false;
        }

        return false;
    }

    public ProgCurveOptionalOperModel getOptionalOperModel() {
        return optionalOperModel;
    }

    public void addAnnealIModel(AnnealIModel annealIModel) {
        getAnnealIModelSet().add(annealIModel);
    }

    public void setOptionalOperModel(ProgCurveOptionalOperModel optionalOperModel) {
        this.optionalOperModel = optionalOperModel;
    }

    /**
     *
     * @return
     */
    public int getAnnealCriterion() {
        return annealCriterion;
    }

    /**
     *
     * @param annealCriterion
     */
    public void setAnnealCriterion(int annealCriterion) {
        this.annealCriterion = annealCriterion;
    }

    public int getSegProbeCount() {
        return segProbeCount;
    }

    public void setSegProbeCount(int segProbeCount) {
        this.segProbeCount = segProbeCount;
    }

    public int getSegmentCount() {
        return segmentCount;
    }

    public void setSegmentCount(int segmentCount) {
        this.segmentCount = segmentCount;
    }

    public Set<AnnealIModel> getAnnealIModelSet() {
        return annealIModelSet;
    }

    public void setAnnealIModelSet(Set<AnnealIModel> annealIModelSet) {
        this.annealIModelSet = annealIModelSet;
    }

    public AnnealIModel getAnnealInputOptions() {
        return annealInputOptions;
    }

    public void setAnnealInputOptions(AnnealIModel annealInputOptions) {
        this.annealInputOptions = annealInputOptions;
    }

    public int getAnnealMachineType() {
        return annealMachineType;
    }

    public void setAnnealMachineType(int annealMachineType) {
        this.annealMachineType = annealMachineType;
    }
}
